home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EuroCD 3
/
EuroCD 3.iso
/
Programming
/
Amos
/
AMOSList-1297
/
AMOSLIST
/
000013_amos-request@svcs1.digex.net_Tue Dec 2 16:45:02 1997.msg
< prev
next >
Wrap
Text File
|
1998-06-24
|
4KB
|
114 lines
Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
by mail2.access.digex.net (8.8.5/8.8.5) with ESMTP id QAA08330
for <mcox@access.digex.net>; Tue, 2 Dec 1997 16:44:54 -0500 (EST)
Received: (from daemon@localhost)
by svcs1.digex.net (8.8.5/8.8.5) id NAA13782
for amos-out; Tue, 2 Dec 1997 13:07:25 -0500 (EST)
Received: from mail3.access.digex.net (mail3.access.digex.net [205.197.247.4])
by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id NAA13777
for <amos-list@svcs1.digex.net>; Tue, 2 Dec 1997 13:07:25 -0500 (EST)
Received: from mailhost.sosbbs.com (sosbbs.com [204.186.168.100])
by mail3.access.digex.net (8.8.5/8.8.5) with SMTP id NAA10919
for <amos-list@access.digex.net>; Tue, 2 Dec 1997 13:07:22 -0500 (EST)
Received: from gbenjam (204.186.168.61) by mailhost.sosbbs.com
(EMWAC SMTPRS 0.81) with SMTP id <B0000150135@mailhost.sosbbs.com>;
Tue, 02 Dec 1997 13:06:16 -0500
Message-ID: <B0000150135@mailhost.sosbbs.com>
From: "Garfield Benjamin" <gbenjam@sosbbs.com>
To: "AMOS MAILING LIST" <amos-list@access.digex.net>
Subject: Re: Fast collisions
Date: Tue, 2 Dec 1997 13:12:23 -0500
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Status: O
X-Status:
> I seem to be stuck on a problem of detecting bob collisions. My
> problems is that I need to test for so many. I have a total of 12
> (or slightly more) objects all of which must look out for eachother.
> Putting the collision detection routine in a loop is far too slow.
> Basically I have to call the collision detection procedure 100+ times
> per frame. Is there an ultra fast way to do this? My game is down
> to about 2 fps. :( Is there any way to do it without getting a
> special extension?
What sort of design are you using?
I normally rely on an optimized program-design to achieve the speed
in my projects, so...
First, you need to set up your procedure _FINDHITNUM as well as
declare the global for it...
Procedure _FINDHITNUM[FIRST, LAST]
HITFLAG=False : Rem ...reset collision-flag
Rem Run through the Col-list to see which Bob was Hit
For CHECKIT=FIRST To LAST
If Col(CHECKIT)
HITFLAG=CHECKIT : Rem ...set flag to ID of object hit
CHECKIT=LAST : Rem ...my way to exit a loop
End If
Next CHECKIT
End Proc
Global HITFLAG
You have 12 objects which need to collide with any of the other 11,
so using Bob Col() you can "quickly" see if an object is colliding
with any of the others...
This can be processed as follows:
For OBJECTNUM=0 to 11
Rem Is this the first object?
If OBJECTNUM=0
Rem yes, so need to check only against all "higher" objects...
If Bob Col(0, 1 To 11 )
_FINDHITNUM[1, 11]
End If
Else
Rem Is this the last object?
If OBJECTNUM=11
Rem yes, so need to check only "lower" objects...
If Bob Col(11, 0 to 10)
_FINDHITNUM[0, 10]
End If
Else
Rem ObjectToCheck is between lowest and highest, so we
Rem need to perform two checks...
Rem One for the objects lower than OBJECTNUM...
If Bob Col(OBJECTNUM, 0 To OBJECTNUM-1)
_FINDHITNUM[0, OBJECTNUM-1]
Else
Rem and a second for objects higher than OBJECTNUM...
If Bob Col(OBJECTNUM, OBJECTNUM+1, 11)
_FINDHITNUM[OBJECTNUM+1, 11]
End If
End If
End If
End If
Rem This object has been checked, so we analyze the result...
If HITFLAG
Rem If here, OBJECTNUM and HITFLAG objects have collided
Rem so, do your processing...
End If
Next OBJECTNUM
This is a reasonably optimized design and AMOS should be able to
sort out the collisions reasonably fast... :)
Let me know how you make out!!
Take care,
GARFIELD
_________________________
Current projects...
SideShooter(AMOS): 85% Complete
Website(http://www.sosbbs.com/~gbenjam): 20% Complete